package com.qf.myblogssm.utils;

import com.qf.myblogssm.pojo.Tarticle;

import java.util.List;

/**
 * create by 王镜 on 2019/6/13 14:52
 */
public class ArticleUtils {
    /**
     * 封装文章时间的处理函数
     * @param articles
     * @return
     */
    public static List<Tarticle> dealTime(List<Tarticle> articles){
        for(Tarticle article:articles){
            article.setTime(article.getTime().substring(0,10));
        }
        return articles;
    }

    /**
     * 封装内容的函数
     * @param articles
     * @return
     */
    public static List<Tarticle> dealContent(List<Tarticle> articles){
        for (Tarticle article:articles){
            if(article.getContent().length()>100){
                article.setContent(article.getContent().substring(0,100)+"............");
            }
        }
        return articles;
    }

    /**
     * 单个的处理时间
     * @param article
     * @return
     */
    public static Tarticle dealArticleTime(Tarticle article){
        article.setTime(article.getTime().substring(0,10));
        return article;
    }
    /**
     * 处理单个文章内容
     * @param article
     * @return
     */
    public static Tarticle dealArticleContent(Tarticle article){
        if(article.getContent().length()>100){
            article.setContent(article.getContent().substring(0,100)+"............");
        }
        return article;
    }
}
